#!/bin/bash

# 进入脚本所在目录（动态获取路径）
BASE_DIR=$(dirname "$(realpath "$0")")
cd "$BASE_DIR" || { echo "目录切换失败"; exit 1; }

# 加载ROS环境
. ~/Desktop/RCIA_Vision/install/setup.bash || { echo "环境加载失败"; exit 1; }

source /home/rcia/intel/oneapi/setvars.sh --force
source /home/rcia/intel/oneapi/ipp/latest/env/vars.sh

# colcon build --packages-select vision_detector

# 动态设置并行构建
NPROC=$(nproc)
colcon build \
  --packages-select vision_detector \
  --parallel-workers $NPROC \
  --cmake-args -DCMAKE_BUILD_TYPE=Release -DWITH_IPP=ON -DIPP_ROOT_DIR=/home/rcia/intel/oneapi/ipp/latest -DCMAKE_PREFIX_PATH=/home/rcia/intel/oneapi

# # 运行节点并记录日志
# ros2 run vision_detector Xin_Main
# ros2 run vision_detector Xin_Main > run.log 2>&1 &
# echo "节点已启动，日志路径: $BASE_DIR/run.log"